import React,{useState} from 'react'
import { useLocation } from 'react-router-dom';
import { goods_list } from '../api/class';
import '../assets/css/class.css'
export default function Class(props) {
  const state = useLocation()
  let queryForm ={
    page: 1,
    list_rows: 10,
    keyword: '',
    cate_id: state?.id || '',
    total: 0
  }

  const [goodList,setGoodList] = useState([]) 
  goods_list(queryForm).then(res=>{
    setGoodList(res.data)
  })

  return (
    <>
      <div className="sort">
        <div>综合排序</div>
        <div>销量</div>
        <div>价格</div>
      </div>   

      <div className="goods_list">
        {
          goodList.map(item=>{
            return <div className="goods_item" key={item.id}>
              <img src={item.goods_logo} alt="" />
              <div className="goods_name" title={item.goods_name}>{ item.goods_name }</div>
              <div className="goods_price">￥{ item.price }</div>
          </div>  
          })
        }
      
    </div>
    
    </>
  )
}

